//
//  MemberViewController.m
//  跨界收
//
//  Created by Allen on 2018/11/4.
//  Copyright © 2018年 gztx. All rights reserved.
//

#import "MemberViewController.h"
#import "WYFCirleView.h"
@interface MemberViewController ()
@property (weak, nonatomic) IBOutlet UIView *cirleView;
@property (weak, nonatomic) IBOutlet UILabel *numberLabel;

@end

@implementation MemberViewController
- (void)pageController:(WMPageController *)pageController lazyLoadViewController:(__kindof UIViewController *)viewController withInfo:(NSDictionary *)info
{//先3 后4
    NSLog(@"%@",info);
    self.navigationItem.title = info[@"title"];
}
- (void)pageController:(WMPageController *)pageController willEnterViewController:(__kindof UIViewController *)viewController withInfo:(NSDictionary *)info
{//先 1 后2 再1
    NSLog(@"%@",info);
    self.navigationItem.title = info[@"title"];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"会员明细";
    [self createCirleProgress];
    
}
- (CGRect)pageController:(WMPageController *)pageController preferredFrameForContentView:(WMScrollView *)contentView
{
    //获取状态栏的rect
    CGRect statusRect = [[UIApplication sharedApplication] statusBarFrame];
    //获取导航栏的rect
    CGRect navRect = self.navigationController.navigationBar.frame;
    return CGRectMake(0, 134, SCREEN_WIDTH, SCREEN_HEIGHT-134-statusRect.size.height- navRect.size.height);
}
- (CGRect)pageController:(WMPageController *)pageController preferredFrameForMenuView:(WMMenuView *)menuView
{
    return CGRectMake(0, 90, SCREEN_WIDTH, 44);
}
- (void)createCirleProgress
{
    NSString *maxString = @"999999";
    CGRect length = [self getSizeWithStr:maxString];
    CGFloat titlelenth = length.size.width;
    CGFloat width = length.size.width+36;
    CGFloat Y = 0;
    if (titlelenth+15 < 75) {
        width = 75;
        Y = 15;
    }
    self.numberLabel.text = maxString;
    WYFCirleView *cirleView = [[WYFCirleView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2.0-(width+8)/2.0, Y, width+8, width+8)];
    cirleView.progerssColor = [UIColor whiteColor];
    cirleView.progerssBackgroundColor = [UIColor colorWithWhite:1 alpha:.5];
    cirleView.percentFontColor = [UIColor whiteColor];
    
    WYFCirleView *cirleView2 = [[WYFCirleView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2.0-width/2.0, Y+4, width, width)];
    cirleView2.progress = width;
    cirleView2.progerssColor = [UIColor whiteColor];
    cirleView2.percentFontColor = [UIColor whiteColor];
    [self.view addSubview:cirleView];
    [self.view addSubview:cirleView2];
    UILabel *numLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2.0-titlelenth/2.0-7.5, width/2.0-10+4+Y, titlelenth, 20)];
    numLabel.text = maxString;
    numLabel.font = [UIFont boldSystemFontOfSize:18.0];
    numLabel.textColor = [UIColor whiteColor];
    [self.view addSubview:numLabel];
    UILabel *renLabel = [[UILabel alloc] initWithFrame:CGRectMake(numLabel.width+numLabel.x, numLabel.y+5, 15, 15)];
    renLabel.font = [UIFont boldSystemFontOfSize:11.0];
    renLabel.text = @"人";
    renLabel.textColor = [UIColor whiteColor];
    [self.view addSubview:renLabel];
}
- (CGRect)getSizeWithStr:(NSString *)str
{
    UIFont *font = [UIFont boldSystemFontOfSize:18.0];
    return [str boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName, nil] context:nil];
}

@end
